﻿using System;
using System.Collections.Generic;
using System.Text;
using PPAP.Model;
using PPAP.DAO;
using System.Data;

namespace PPAP.BO
{
    public class SamplecardBO
    {
        public SamplecardBO() { }
        SamplecardDAO dao = new SamplecardDAO();
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Samplecard model)
        {
            return dao.Add(model);
        }

        /// <summary>
        /// re-submit  re-inpsection
        /// </summary>
        public int ReAdd(Samplecard model)
        {
            return dao.ReAdd(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(Samplecard model)
        {
            return dao.Update(model);
        }

        public List<Samplecard> GetListForPPAR(string pid)
        {
            return dao.GetListForPPAR(pid);
        }

        /// <summary>
        /// 重新分配
        /// </summary>
        public int UpdateDEPTREP(Samplecard model)
        {
            return dao.UpdateDEPTREP(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public int Delete(int id)
        {
            return dao.Delete(id);
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Samplecard GetModel(int id)
        {
            return dao.GetModel(id);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dao.GetList(strWhere);
        }

        /// <summary>
        /// 获取测试人员任务 包括权限代理任务
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public DataSet GetListForUser(string user,string sort)
        {
            return dao.GetListForUser(user,sort);
        }

        /// <summary>
        /// 根据PPARid查询Sample状态
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public DataSet GetSampleResult(string pparid)
        {
            return dao.GetSampleResult(pparid);
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sqlwhere"></param>
        /// <returns></returns>
        public DataSet GetSampleForSearch(string sqlwhere)
        {
            return dao.GetSampleForSearch(sqlwhere);
        }

        /// <summary>
        /// 用于判断该PPAR是否有未检测完成的样品  不包括已终止的card
        /// </summary>
        /// <param name="pparid"></param>
        /// <returns></returns>
        public int GetNoPassSample(string pparid)
        {
            return dao.GetNoPassSample(pparid);
        }

        /// <summary>
        /// Print
        /// </summary>
        /// <param name="SampleCardId"></param>
        /// <returns></returns>
        public DataSet GetPrint(string SampleCardId)
        {
            return dao.GetPrint(SampleCardId);
        }

        /// <summary>
        /// 获取SampleCardName
        /// </summary>
        /// <param name="SampleCardId"></param>
        /// <returns></returns>
        public DataSet GetSampleCardName(int? SampleCardId)
        {
            return dao.GetSampleCardName(SampleCardId);
        }

        /// <summary>
        /// 判断一个PPAR下的CARD是否全部检测结束
        /// </summary>
        /// <param name="samplecardid"></param>
        /// <returns></returns>
        public bool CheckSampleCardPass(int samplecardid)
        {
            return dao.CheckSampleCardPass(samplecardid);
        }

        /// <summary>
        /// 终止指定ppar下的所有card
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public int DeleteCardByPid(int pid)
        {
            return dao.DeleteCardByPid(pid);
        }
    }
}
